package org.jeecg.modules.carRecord.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.carRecord.entity.CarRecord;
import org.jeecg.modules.carRecord.mapper.CarRecordMapper;
import org.jeecg.modules.carRecord.service.ICarRecordService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Description: 车辆进出记录
 * @Author: jeecg-boot
 * @Date:   2024-07-24
 * @Version: V1.0
 */
@Service
public class CarRecordServiceImpl extends ServiceImpl<CarRecordMapper, CarRecord> implements ICarRecordService {

    @Override
    public CarRecord getLastByPlateNo(String plateNo) {
        LambdaQueryWrapper<CarRecord> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(CarRecord::getPlateNo, plateNo);
        wrapper.isNull(CarRecord::getExitPic);
        wrapper.isNull(CarRecord::getExitTime);
        wrapper.orderByDesc(CarRecord::getCreateTime);
        wrapper.last("limit 1");
        return baseMapper.selectOne(wrapper);
    }

    @Override
    public List<Map<String, Object>> getCount() {
        return baseMapper.getCount();
    }

    @Override
    public int getTodayInCount() {
        return baseMapper.getTodayInCount();
    }
}
